import { createRouter, createWebHashHistory } from "vue-router";
import Home from "./pages/Home.vue";
import Banner from "./pages/Banners.vue";
import Post from "./pages/Post.vue";
import Comment from "./pages/Comment.vue";
import User from "./pages/User.vue";

// 2. 定义一些路由,每个路由都需要映射到一个组件(页面)。
const routes = [
    { path: '/', component: Home, name: "home" },
    { path: '/banners', component: Banner, name: "banners" },
    { path: '/post', component: Post, name: "post" },
    { path: '/comment', component: Comment, name: "comment" },
    { path: '/user', component: User, name: "user" }
]

// 3. 创建路由实例并传递 `routes` 配置
const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
})

export default router;